<?php 
if(KT!='KhiThe') exit;
class rates_model extends khithe_mysql{

	public function getrates()
	{		
		$select = "SELECT * FROM ".rates." ";
		$result = parent::SelectMySQL($select);
		parent::CloseConnection();
		return$result; 
	}
	
	public function getrateID($ID){
		
		$ID = parent::checkStrMySQL($ID);
		$select = "SELECT * FROM ".rates." WHERE ID = '".$ID."'";
		$result= parent::SelectMySQL($select);
		parent::CloseConnection();
		return $result;
	}
	
	public function setCheckedrate($ID,$Val)
	{
		$ID = parent::checkStrMySQL($ID);
		$update = "UPDATE ".rates." SET Status='".$Val."'  WHERE ID = '".$ID."'";
		parent::CloseConnection();
		return parent::UpdateInsertMySQL($update);
	}
	
	public function delCheckedrate($ID)
	{
		$ID = parent::checkStrMySQL($ID);
		$del = "DELETE FROM ".rates." WHERE ID='".$ID."' ";
		parent::CloseConnection();
		return parent::DeleteMySQL($del);
	}
	
	public function updateInsertrate($_POST)
	{
		$ID = parent::checkStrMySQL($_POST['ratesID']);
		$Ratename = parent::checkStrMySQL($_POST['txt_Ratename']);
		$Rate = parent::checkStrMySQL($_POST['txt_Rate']);
		if($this->valUrl(0)=='edit'){
			$query = "UPDATE ".rates." SET Ratename='".$Ratename."',Rate='".$Rate."',PostDate='".time()."' WHERE ID = '".trim($ID)."'";
		
		}else if($this->valUrl(0)=='add'){
			$query = "INSERT INTO ".rates."(Ratename,Rate,PostDate,`Status`)VALUES('".$Ratename."','".$Rate."','".time()."','false')";
		}
		
		parent::CloseConnection();
		return parent::UpdateInsertMySQL($query);
		
	}
}
?>